/*******************************************************************/
/* @ All Rights Reserved Copyright (C) 2014 broada,Co.,Ltd.        */
/*                                                                 */
/*  NAME      = frstat_ct_all.c                                  */
/*  NOTE      =                                                    */
/*  DATE      = 2015/02/03 by geyh                                 */
/*******************************************************************/

#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <CUnit/Basic.h>
#include <CUnit/CUnit.h>

#include "frcomm.h"
#include "frmem.h"
#include "frhash2.h"
#include "frlist.h"
#include "frsutl.h"
#include "frstat_ct.h"
#include "conntrack.h"
#include "module_comm.h"
#include "module.h"
#include "apmtest_cunit.h"

static int __suite_init(void)
{
	return 0;
}

static int __suite_cleanup(void)
{
	return 0;
}

//extern int frstat_ct_conns_init(void);
//extern void frstat_ct_conns_destroy(void);

void case1(void)
{
    int i_ret = 0;
    char *p_result = NULL;
    int accept_sock = 1;
    Conntrack *p_st_ct = NULL;

//frstat_ct_conns_init();

    p_st_ct = (Conntrack *)frmalloc(sizeof(Conntrack));
    memset(p_st_ct, 0x00, sizeof(Conntrack));

    i_ret = frstat_ct_all(&p_result, (void *)accept_sock);

    CU_ASSERT_EQUAL(i_ret,FR_SUCC);
    CU_ASSERT_STRING_EQUAL(p_result,"total conns:0\tdead conns:0\n");
    //frdbg("\t%s\n",p_result);

//frstat_ct_conns_destroy();

    frfree(p_st_ct);
    frfree(p_result);
    return;

}


int add_suite()
{
	CU_pSuite pSuite = NULL;

	pSuite = CU_add_suite("t_frstat_ct_all 测试", __suite_init, __suite_cleanup);

	if (NULL == pSuite)
	{
		return 1;
	}


    //增加测试用例
   	CU_add_test(pSuite, "case1", case1);


    return 0;

}

int main(int argc, char **argv)
{
    fr_slab_init(52428800, "test");
    run_cunit(add_suite);
    fr_slab_destroy();

    return 0;
}